package crud.client.data;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;

import com.google.gwt.user.client.rpc.IsSerializable;

@Entity(name="CATALOGUE")
@IdClass(CataloguePk.class)
public class Catalogue implements Serializable, IsSerializable
{
	@Column(name="ABREVIATION")
 	private String abreviation; 
	
	@Column(name="LIBELLE")
	private String libelle; 
	
	@Column(name="LIBELLE_LONG")
	private String libelleLong;
	
	@Column(name="CODE_TABLE")
	private String codeTable;
	
	@Column(name="CODE_DETAIL")
	private String codeDetail;

	@Column(name="ORDRE", nullable=false)
	private int ordre;
	
	public Catalogue(){}
	

	
	public Catalogue(String codeTable, String codeDetail, String libelle)
	{
		super();
		this.codeTable = codeTable;
		this.codeDetail = codeDetail;
		this.libelle = libelle;
		this.libelleLong = libelle;
		this.abreviation = libelle;
	}



	@Id public String getCodeTable()
	{
		return codeTable;
	}

	@Column(name="CODE_TABLE")
	public void setCodeTable(String codeTable)
	{
		this.codeTable = codeTable;
	}

	@Column(name="CODE_DETAIL")
	@Id public String getCodeDetail()
	{
		return codeDetail;
	}

	public void setCodeDetail(String codeDetail)
	{
		this.codeDetail = codeDetail;
	}

	@Column(name="ABREVIATION")
	public String getAbreviation()
	{
		return abreviation;
	}
	public void setAbreviation(String abreviation)
	{
		this.abreviation = abreviation;
	}
	@Column(name="LIBELLE")
	public String getLibelle()
	{
		return libelle;
	}
	public void setLibelle(String libelle)
	{
		this.libelle = libelle;
	}
	@Column(name="LIBELLE_LONG")
	public String getLibelleLong()
	{
		return libelleLong;
	}
	public void setLibelleLong(String libelleLong)
	{
		this.libelleLong = libelleLong;
	}
	

	@Override
	public boolean equals(Object catalogue)
	{
		return 
			this.getCodeTable().equals(((Catalogue) catalogue).getCodeTable()) && 
			this.getCodeDetail().equals((((Catalogue) catalogue).getCodeDetail())); 
	}

	@Override
	public int hashCode()
	{
		return 
			3 * this.getCodeTable().hashCode() + 
			5 * this.getCodeDetail().hashCode();
	}

	public void setCode(String code)
	{
		setCodeDetail(code);
	}

	@Column(name="ORDRE", nullable=false)
	public int getOrdre()
	{
		return ordre;
	}

	public void setOrdre(int ordre)
	{
		this.ordre = ordre;
	}	

	
}
